<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 
        计算属性能实现的功能使用函数都能实现

        计算属性有缓存的一个特点


     -->

    <div id="app">
        <button @click="first+='~'">First: {{ first }}</button>
        <button @click="last+='!'">Last: {{ last }}</button>

        <hr />
        <p>FullName - method: {{ fullNameTwo() }}</p>
        <p>FullName - method: {{ fullNameTwo() }}</p>
        <p>FullName - method: {{ fullNameTwo() }}</p>

        <p>FullName - computed: {{ fullName }}</p>
        <p>FullName - computed: {{ fullName }}</p>
        <p>FullName - computed: {{ fullName }}</p>
    </div>

    <script type="module">
        import { createApp } from './lib/vue3.esm.browser.js'


        createApp({

            data() {
                return {
                    first: '张',
                    last: '三',
                }
            },

            computed: {
                fullName() {
                    console.log('computed')
                    return this.first + '' + this.last
                }
            },

            methods: {
                fullNameTwo() {
                    console.log('methods')
                    return this.first + '' + this.last
                }
            }

        }).mount('#app')
    </script>
</body>

</html>